# create_sample_db.py
import sqlite3

def create_sample_database():
    """创建一个示例 SQLite 数据库和表"""
    conn = sqlite3.connect('sample.db')
    cursor = conn.cursor()

    # 创建 employees 表
    cursor.execute('''
        CREATE TABLE IF NOT EXISTS employees (
            id INTEGER PRIMARY KEY,
            name TEXT NOT NULL,
            department TEXT NOT NULL,
            salary REAL NOT NULL,
            age INTEGER NOT NULL
        )
    ''')

    # 插入示例数据
    sample_data = [
        (1, 'Alice', 'Engineering', 75000.0, 30),
        (2, 'Bob', 'Sales', 65000.0, 25),
        (3, 'Charlie', 'Engineering', 80000.0, 35),
        (4, 'Diana', 'Marketing', 70000.0, 28),
        (5, 'Eve', 'Sales', 68000.0, 32),
    ]

    cursor.executemany('INSERT OR REPLACE INTO employees VALUES (?, ?, ?, ?, ?)', sample_data)
    conn.commit()
    conn.close()
    print("✅ 示例数据库 'sample.db' 创建成功！")

if __name__ == "__main__":
    create_sample_database()